cordova.define("com.mocoop.plugin.pages.PageController", function(require, exports, module) {

    var exec = require('cordova/exec');
    var platform = require('cordova/platform');

    module.exports = {

        jumNewPage: function(pageJumpsInfo,callback) {
            cordova.fireDocumentEvent('ViewDidDisappear');
            exec(function(){

            }, null, "PageController", "jumpNewPage", [pageJumpsInfo]);
        },
        showMeRightNow: function() {
            cordova.fireDocumentEvent('ViewDidAppear');
            exec(function(){

            }, null, "PageController", "showMeRightNow", [""]);
        },
        goback:function(){
            cordova.fireDocumentEvent('ViewDidDisappear');
            exec(function(){

            }, null, "PageController", "goBack", [""]);
        },
        backToSpecifyPage:function(targetPage){
            cordova.fireDocumentEvent('ViewDidDisappear');
            exec(function(){

            }, null, "PageController", "backToSpecifyPage", [targetPage]);
        },
        jumpToSubAppPage: function (subAppID, pageJumpsInfo, callback) {
            var succeed = function () {
                if ((callback == undefined) || (callback == null)) {
                    return;
                }

                var returnedObjForCallback = new Object();
                returnedObjForCallback.result = true;
                callback(returnedObjForCallback);
            };
            var failed = function (error) {
                if ((callback == undefined) || (callback == null)) {
                    return;
                }

                var returnedObjForCallback = new Object();
                returnedObjForCallback.result = false;
                returnedObjForCallback.error = error;
                callback(returnedObjForCallback);
            };
            exec(succeed, failed, "PageController", "jumpToSubAppPage", [ subAppID, pageJumpsInfo ]);
        }
    };

});


function jumpToPage(pageJumpsInfo, callback) {
    navigator.PageController.jumNewPage(pageJumpsInfo,callback);
}

// 跳转到子应用的页面
function jumpToSubAppPage(subAppID, pageJumpsInfo, callback) {
    navigator.PageController.jumpToSubAppPage(subAppID, pageJumpsInfo, callback);
}

// 通知平台页面准备好了, 可以立即显示
function showMeRightNow(callback) {
    navigator.PageController.showMeRightNow();
}

// 返回到上一个页面
function backToForwardPage() {
    navigator.PageController.goback();
}
function backToSpecifyPage(targetPage){
    navigator.PageController.backToSpecifyPage(targetPage);
}